(function webpackUniversalModuleDefinition(root, factory) {
	if(typeof exports === 'object' && typeof module === 'object')
		module.exports = factory();
	else if(typeof define === 'function' && define.amd)
		define([], factory);
	else if(typeof exports === 'object')
		exports["GraphBack"] = factory();
	else
		root["GraphBack"] = factory();
})(self, () => {
return /******/ (() => { // webpackBootstrap
/******/ 	"use strict";
/******/ 	var __webpack_modules__ = ({

/***/ 354:
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {


Object.defineProperty(exports, "__esModule", ({ value: true }));
const group_1 = __webpack_require__(926);
class Board extends group_1.Group {
    constructor(element, props) {
        super(props);
        this.children = [];
        this.canvas = document.createElement('canvas');
        this.ctx = this.canvas.getContext('2d');
        this.devicePixelRatio = 1;
        this.element = null;
        this.height = 0;
        this.width = 0;
        this.centerX = 0;
        this.centerY = 0;
        this.animated = false;
        this.create = false;
        this.element = element;
        this.create = props === null || props === void 0 ? void 0 : props.create;
        this.canvas.width = this.canvas.height = 0;
        // 增加child
        if (this.create) {
            this.element.style.overflow = 'hidden';
            this.element.innerHTML = '';
            this.element.appendChild(this.canvas);
        }
        this.devicePixelRatio = window.devicePixelRatio || 1;
        // 高清适配
        this.matrix.matrix = this.matrix.scaleTo(this.devicePixelRatio, this.devicePixelRatio);
        this.resize();
    }
    render() {
        this.draw(this.ctx);
    }
    animate() {
        if (!this.animated)
            return;
        this.render();
        window.requestAnimationFrame(() => this.animate());
    }
    resize() {
        this.height = this.element.clientHeight;
        this.width = this.element.clientWidth;
        this.centerX = this.width / 2;
        this.centerY = this.height / 2;
        this.canvas.style.width = this.width + 'px';
        this.canvas.style.height = this.height + 'px';
        this.canvas.width = this.width * this.devicePixelRatio;
        this.canvas.height = this.height * this.devicePixelRatio;
        if (!this.animated)
            this.render();
    }
    draw(ctx) {
        // 清除因为变换清除不掉的像素
        ctx.resetTransform();
        // 清除画布
        ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
        // 变换矩阵
        // @ts-ignore
        ctx.setTransform(...this.matrix.matrix);
        // 绘制模型
        for (let i = 0; i < this.children.length; i++) {
            this.children[i].draw(ctx);
        }
    }
    clearRect(x, y, width, height) {
        this.ctx.clearRect(x, y, width, height);
    }
    getUrl() {
        this.render();
        return this.canvas.toDataURL('image/png');
    }
    getStyle() {
        return `url(${this.getUrl()}) 0 0/100% 100%`;
    }
    setPath() { }
    drawPath(ctx) { }
}
exports["default"] = Board;


/***/ }),

/***/ 148:
/***/ ((__unused_webpack_module, exports) => {


Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.LineGradient = void 0;
class LineGradient {
    constructor(x0, y0, x1, y1) {
        this._x0 = 0;
        this._y0 = 0;
        this._x1 = 100;
        this._y1 = 0;
        this.canvas = document.createElement('canvas');
        this.ctx = this.canvas.getContext('2d');
        this._x0 = x0;
        this._y0 = y0;
        this._x1 = x1;
        this._y1 = y1;
        this.gradient = this.ctx.createLinearGradient(this._x0, this._y0, this._x1, this._y1);
    }
    add(offset, color) {
        this.gradient.addColorStop(offset, color);
    }
    get() {
        return this.gradient;
    }
}
exports.LineGradient = LineGradient;


/***/ }),

/***/ 621:
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {


Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.BaseGraph = void 0;
const matrix_1 = __webpack_require__(799);
/**
 * 图形基础参数
 */
class BaseGraph {
    constructor(props) {
        var _a, _b, _c, _d;
        this.defaultOption = {
            direction: 'ltr',
            fillStyle: '#000000',
            filter: 'none',
            font: '10px sans-serif',
            fontKerning: 'auto',
            fontStretch: 'normal',
            fontVariantCaps: 'normal',
            globalAlpha: 1,
            globalCompositeOperation: 'source-over',
            imageSmoothingEnabled: true,
            imageSmoothingQuality: 'low',
            letterSpacing: '0px',
            lineCap: 'butt',
            lineDashOffset: 0,
            lineJoin: 'miter',
            lineWidth: 1,
            miterLimit: 10,
            shadowBlur: 0,
            shadowColor: 'rgba(0, 0, 0, 0)',
            shadowOffsetX: 0,
            shadowOffsetY: 0,
            strokeStyle: '#000000',
            textAlign: 'start',
            textBaseline: 'alphabetic',
            textRendering: 'auto',
            wordSpacing: '0px'
        };
        this.option = {};
        this.type = 'base';
        this.isFill = true;
        this._x = 0;
        this._y = 0;
        this._rotate = 0;
        this._scaleX = 1;
        this._scaleY = 1;
        this._skewX = 0;
        this._skewY = 0;
        this._origin = 'none';
        this.ctx = null;
        this.matrix = new matrix_1.default();
        this.path = new Path2D();
        this.option = props;
        this.setOption();
        this.isFill = (props === null || props === void 0 ? void 0 : props.fill) == undefined ? this.isFill : props === null || props === void 0 ? void 0 : props.fill;
        this._x = (props === null || props === void 0 ? void 0 : props.x) || this._x;
        this._y = (props === null || props === void 0 ? void 0 : props.y) || this._y;
        this._rotate = (props === null || props === void 0 ? void 0 : props.rotate) || this._rotate;
        this._scaleX = ((_a = props === null || props === void 0 ? void 0 : props.scale) === null || _a === void 0 ? void 0 : _a.x) || (props === null || props === void 0 ? void 0 : props.scaleX) || this._scaleX;
        this._scaleY = ((_b = props === null || props === void 0 ? void 0 : props.scale) === null || _b === void 0 ? void 0 : _b.y) || (props === null || props === void 0 ? void 0 : props.scaleY) || this._scaleY;
        this._skewX = ((_c = props === null || props === void 0 ? void 0 : props.skew) === null || _c === void 0 ? void 0 : _c.x) || (props === null || props === void 0 ? void 0 : props.skewX) || this._skewX;
        this._skewY = ((_d = props === null || props === void 0 ? void 0 : props.skew) === null || _d === void 0 ? void 0 : _d.y) || (props === null || props === void 0 ? void 0 : props.skewY) || this._skewY;
        this._origin = (props === null || props === void 0 ? void 0 : props.origin) || this._origin;
        this.setTransform();
    }
    setOption(props) {
        var _a, _b, _c, _d, _e;
        this.defaultOption = Object.assign(Object.assign(Object.assign({}, this.defaultOption), props), this.option);
        // 处理一下color和alpha
        this.defaultOption.fillStyle =
            ((_a = this.option) === null || _a === void 0 ? void 0 : _a.fillStyle) || ((_b = this.option) === null || _b === void 0 ? void 0 : _b.color) || (props === null || props === void 0 ? void 0 : props.fillStyle) || (props === null || props === void 0 ? void 0 : props.color) || this.defaultOption.fillStyle;
        this.defaultOption.strokeStyle = ((_c = this.option) === null || _c === void 0 ? void 0 : _c.strokeStyle) || (props === null || props === void 0 ? void 0 : props.strokeStyle) || this.defaultOption.fillStyle;
        this.defaultOption.globalAlpha =
            ((_d = this.option) === null || _d === void 0 ? void 0 : _d.globalAlpha) ||
                ((_e = this.option) === null || _e === void 0 ? void 0 : _e.alpha) ||
                (props === null || props === void 0 ? void 0 : props.globalAlpha) ||
                (props === null || props === void 0 ? void 0 : props.alpha) ||
                this.defaultOption.globalAlpha;
    }
    /**
     * 设置当前图形的样式
     * @param ctx
     */
    initStyle(ctx) {
        ctx.direction = this.defaultOption.direction;
        ctx.fillStyle =
            typeof this.defaultOption.fillStyle == 'string'
                ? this.defaultOption.fillStyle
                : this.defaultOption.fillStyle.get();
        ctx.filter = this.defaultOption.filter;
        ctx.font = this.defaultOption.font;
        ctx.fontKerning = this.defaultOption.fontKerning;
        // @ts-ignore
        ctx.fontStretch = this.defaultOption.fontStretch;
        // @ts-ignore
        ctx.fontVariantCaps = this.defaultOption.fontVariantCaps;
        ctx.globalAlpha = this.defaultOption.globalAlpha;
        ctx.globalCompositeOperation = this.defaultOption.globalCompositeOperation;
        ctx.imageSmoothingEnabled = this.defaultOption.imageSmoothingEnabled;
        ctx.imageSmoothingQuality = this.defaultOption.imageSmoothingQuality;
        // @ts-ignore
        ctx.letterSpacing = this.defaultOption.letterSpacing;
        ctx.lineCap = this.defaultOption.lineCap;
        ctx.lineDashOffset = this.defaultOption.lineDashOffset;
        ctx.lineJoin = this.defaultOption.lineJoin;
        ctx.lineWidth = this.defaultOption.lineWidth;
        ctx.miterLimit = this.defaultOption.miterLimit;
        ctx.shadowBlur = this.defaultOption.shadowBlur;
        ctx.shadowColor = this.defaultOption.shadowColor;
        ctx.shadowOffsetX = this.defaultOption.shadowOffsetX;
        ctx.shadowOffsetY = this.defaultOption.shadowOffsetY;
        ctx.strokeStyle =
            typeof this.defaultOption.strokeStyle == 'string'
                ? this.defaultOption.strokeStyle
                : this.defaultOption.strokeStyle.get();
        ctx.textAlign = this.defaultOption.textAlign;
        ctx.textBaseline = this.defaultOption.textBaseline;
        // @ts-ignore
        ctx.textRendering = this.textRendering;
    }
    /**
     * 绘制图形
     * @param ctx
     */
    draw(ctx) {
        ctx.save();
        let a = ctx.getTransform();
        let m1 = [a.a, a.b, a.c, a.d, a.e, a.f];
        let m2 = this.matrix.multiply(m1, this.matrix.matrix);
        ctx.setTransform(...m2);
        ctx.beginPath();
        this.initStyle(ctx);
        this.drawPath(ctx);
        ctx.restore();
    }
    /**
     * 设置变换
     */
    setTransform() {
        let offsetX = 0;
        let offsetY = 0;
        if (typeof this._origin == 'string') {
            if (this._origin == 'center') {
                let sphere = this.getBoundBox();
                offsetX = sphere.width / 2;
                offsetY = sphere.height / 2;
            }
        }
        else {
            offsetX = this._origin.x;
            offsetY = this._origin.y;
        }
        this.matrix.reset();
        this.matrix.transform([
            this.matrix.translateMatrix(-offsetX, -offsetY),
            this.matrix.scaleMatrix(this._scaleX, this._scaleY),
            this.matrix.rotateMatrix(this._rotate),
            this.matrix.skewMatrix(this._skewX, this._skewY),
            this.matrix.translateMatrix(this.x + offsetX, this.y + offsetY)
        ]);
    }
    /**
     * 设置图形位置
     * @param x 水平方向位置
     * @param y 垂直方向位置
     */
    translate(x, y) {
        this._x = x;
        this._y = y;
        this.setTransform();
    }
    /**
     * 水平方向位置
     */
    set x(value) {
        this._x = value;
        this.setTransform();
    }
    get x() {
        return this._x;
    }
    /**
     * 垂直方向位置
     */
    set y(value) {
        this._y = value;
        this.setTransform();
    }
    get y() {
        return this._y;
    }
    /**
     * 图形旋转
     */
    set rotate(angle) {
        this._rotate = angle;
        this.setTransform();
    }
    get rotate() {
        return this._rotate;
    }
    /**
     * 图形缩放
     */
    scale(x, y) {
        this._scaleX = x;
        this._scaleY = y || x;
        this.setTransform();
    }
    /**
     * 获取图形缩放值
     * @returns x, y
     */
    getScale() {
        return { x: this._scaleX, y: this._scaleY };
    }
    /**
     * 图像水平方向缩放
     */
    set scaleX(value) {
        this._scaleX = value;
        this.setTransform();
    }
    get scaleX() {
        return this._scaleX;
    }
    /**
     * 图像垂直方向缩放
     */
    set scaleY(value) {
        this._scaleY = value;
        this.setTransform();
    }
    get scaleY() {
        return this._scaleY;
    }
    skew(skewX, skewY) {
        this._skewX = skewX;
        this._skewY = skewY || skewX;
        this.setTransform();
    }
    getSkew() {
        return { x: this._skewX, y: this._skewY };
    }
    set skewX(value) {
        this._skewX = value;
        this.setTransform();
    }
    get skewX() {
        return this._skewY;
    }
    set skewY(value) {
        this._skewY = value;
        this.setTransform();
    }
    get skewY() {
        return this._skewY;
    }
    set origin(value) {
        this._origin = value;
        this.setTransform();
    }
    get origin() {
        return this._origin;
    }
    getBaseCloneAttr() {
        return {
            x: this._x,
            y: this._y,
            rotate: this._rotate,
            scaleX: this._scaleX,
            scaleY: this._scaleY,
            skewX: this._skewX,
            skewY: this._skewY,
            origin: this._origin
        };
    }
}
exports.BaseGraph = BaseGraph;


/***/ }),

/***/ 423:
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {


Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.Circle = void 0;
const base_1 = __webpack_require__(621);
/**
 * 圆形
 */
class Circle extends base_1.BaseGraph {
    constructor(props) {
        super(props);
        this.radius = 10;
        this.startAngle = 0;
        this.endAngle = Math.PI * 2;
        this.counterclockwise = true;
        this.type = 'circle';
        this.radius = (props === null || props === void 0 ? void 0 : props.radius) || this.radius;
        this.startAngle = (props === null || props === void 0 ? void 0 : props.startAngle) || this.startAngle;
        this.endAngle = (props === null || props === void 0 ? void 0 : props.endAngle) || this.endAngle;
        this.counterclockwise = (props === null || props === void 0 ? void 0 : props.counterclockwise) || this.counterclockwise;
        this.setPath();
    }
    setPath() {
        delete this.path;
        this.path = new Path2D();
        this.path.arc(0, 0, this.radius, this.startAngle, this.endAngle, this.counterclockwise);
    }
    drawPath(ctx) {
        if (this.isFill)
            ctx.fill(this.path);
        else
            ctx.stroke(this.path);
    }
    clone() {
        return new Circle(Object.assign(Object.assign(Object.assign({}, this.option), this.getBaseCloneAttr()), { radius: this.radius, startAngle: this.startAngle, endAngle: this.endAngle, counterclockwise: this.counterclockwise }));
    }
    getBoundBox() {
        return {
            top: this.y - this.radius,
            bottom: this.y + this.radius,
            left: this.x - this.radius,
            right: this.x + this.radius,
            width: this.radius * 2,
            height: this.radius * 2
        };
    }
}
exports.Circle = Circle;


/***/ }),

/***/ 926:
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {


Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.Group = void 0;
const base_1 = __webpack_require__(621);
class Group extends base_1.BaseGraph {
    constructor(props) {
        super(props);
        this.children = [];
    }
    add(graph) {
        if (graph.type == 'text' || graph.type == 'group') {
            graph.ctx = this.ctx;
            graph.setPath();
        }
        graph.setOption(this.option);
        this.children.push(graph);
    }
    draw(ctx) {
        for (let i = 0; i < this.children.length; i++) {
            this.children[i].draw(ctx);
        }
    }
    clone() {
        let group = new Group(Object.assign(Object.assign({}, this.option), this.getBaseCloneAttr()));
        group.children = this.children.map((item) => item.clone());
        return group;
    }
    getBoundBox() {
        let top = Infinity;
        let left = Infinity;
        let bottom = -Infinity;
        let right = -Infinity;
        for (let i = 0; i < this.children.length; i++) {
            let box = this.children[i].getBoundBox();
            top = top < box.top ? top : box.top;
            left = left < box.left ? left : box.left;
            bottom = bottom > box.bottom ? bottom : box.bottom;
            right = right > box.right ? right : box.right;
        }
        return { top, left, bottom, right, width: right - left, height: bottom - top };
    }
    setPath() { }
    drawPath(ctx) { }
}
exports.Group = Group;


/***/ }),

/***/ 718:
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {


Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.Path = void 0;
const base_1 = __webpack_require__(621);
class Path extends base_1.BaseGraph {
    constructor(props) {
        super(props);
        this.pathString = '';
        this.type = 'path';
        this.option.strokeStyle = this.option.fillStyle;
        this.option.lineWidth = this.option.lineWidth || 1;
        this.pathString = props.path;
        this.setPath();
    }
    setPath() {
        delete this.path;
        this.path = new Path2D(this.pathString);
    }
    drawPath(ctx) {
        if (this.isFill)
            ctx.fill(this.path);
        else
            ctx.stroke(this.path);
    }
    clone() {
        return new Path(Object.assign(Object.assign(Object.assign({}, this.option), this.getBaseCloneAttr()), { path: this.pathString }));
    }
    getBoundBox() {
        let minX = Infinity;
        let maxX = -Infinity;
        let minY = Infinity;
        let maxY = -Infinity;
        return {
            top: minY + this.y,
            bottom: maxY + this.y,
            left: minX + this.x,
            right: maxX + this.x,
            width: maxX - minX,
            height: maxY - minY
        };
    }
}
exports.Path = Path;


/***/ }),

/***/ 623:
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {


Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.Polygon = void 0;
const polyline_1 = __webpack_require__(931);
class Polygon extends polyline_1.Polyline {
    constructor(props) {
        super(props);
        this.type = 'polygon';
    }
    drawPath(ctx) {
        ctx.fill(this.path);
    }
    clone() {
        return new Polygon(Object.assign(Object.assign(Object.assign({}, this.option), this.getBaseCloneAttr()), { points: JSON.parse(JSON.stringify(this._points)), smooth: this._smooth, close: this._close }));
    }
}
exports.Polygon = Polygon;


/***/ }),

/***/ 931:
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {


Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.Polyline = void 0;
const base_1 = __webpack_require__(621);
class Polyline extends base_1.BaseGraph {
    constructor(props) {
        super(props);
        this._points = [];
        this._smooth = false;
        this._close = false;
        this._tension = 0.5;
        this.type = 'polyline';
        this.defaultOption.strokeStyle = this.defaultOption.fillStyle;
        this._points = props.points;
        this._smooth = !!props.smooth;
        this._close = !!props.close;
        this.setPath();
    }
    getCatmullRomControlPoints(p0, p1, p2, p3) {
        const cp1x = p1[0] + ((p2[0] - p0[0]) / 6) * this._tension;
        const cp1y = p1[1] + ((p2[1] - p0[1]) / 6) * this._tension;
        const cp2x = p2[0] - ((p3[0] - p1[0]) / 6) * this._tension;
        const cp2y = p2[1] - ((p3[1] - p1[1]) / 6) * this._tension;
        return { cp1x, cp1y, cp2x, cp2y };
    }
    setPath() {
        delete this.path;
        this.path = new Path2D();
        if (this._points.length == 0)
            return;
        this.path.moveTo(this._points[0][0], this._points[0][1]);
        if (this._smooth && this._points.length > 2) {
            let first = this._points[0];
            let end = this._points[this._points.length - 1];
            let result = [];
            if (this._close)
                result = [end, ...this._points, first, this._points[1]];
            else
                result = [first, ...this._points, end];
            for (let i = 1; i < result.length - 2; i++) {
                let p = this.getCatmullRomControlPoints(result[i - 1], result[i], result[i + 1], result[i + 2]);
                this.path.bezierCurveTo(p.cp1x, p.cp1y, p.cp2x, p.cp2y, result[i + 1][0], result[i + 1][1]);
            }
            if (this._close)
                this.path.closePath();
        }
        else {
            // 折线
            for (let i = 1; i < this._points.length; i++) {
                this.path.lineTo(this._points[i][0], this._points[i][1]);
            }
            if (this._close)
                this.path.closePath();
        }
    }
    drawPath(ctx) {
        ctx.stroke(this.path);
    }
    clone() {
        return new Polyline(Object.assign(Object.assign(Object.assign({}, this.option), this.getBaseCloneAttr()), { points: JSON.parse(JSON.stringify(this._points)), smooth: this._smooth, close: this._close }));
    }
    getBoundBox() {
        let minX = Infinity;
        let maxX = -Infinity;
        let minY = Infinity;
        let maxY = -Infinity;
        for (let i = 0; i < this._points.length; i++) {
            let p = this._points[i];
            minX = minX < p[0] ? minX : p[0];
            minY = minY < p[1] ? minY : p[1];
            maxX = maxX > p[0] ? maxX : p[0];
            maxY = maxY > p[1] ? maxY : p[1];
        }
        return {
            top: minY + this.y,
            bottom: maxY + this.y,
            left: minX + this.x,
            right: maxX + this.x,
            width: maxX - minX,
            height: maxY - minY
        };
    }
}
exports.Polyline = Polyline;


/***/ }),

/***/ 317:
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {


Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.Rect = void 0;
const base_1 = __webpack_require__(621);
let index = 0;
/**
 * 圆形
 */
class Rect extends base_1.BaseGraph {
    constructor(props) {
        super(props);
        this.width = 100;
        this.height = 100;
        this.uuid = 0;
        this.type = 'rect';
        this.uuid = index++;
        this.width = (props === null || props === void 0 ? void 0 : props.width) || this.width;
        this.height = (props === null || props === void 0 ? void 0 : props.height) || this.height;
        this.setPath();
    }
    setPath() {
        delete this.path;
        this.path = new Path2D();
        this.path.rect(0, 0, this.width, this.height);
    }
    drawPath(ctx) {
        if (this.isFill)
            ctx.fill(this.path);
        else
            ctx.stroke(this.path);
    }
    clone() {
        return new Rect(Object.assign(Object.assign(Object.assign({}, this.option), this.getBaseCloneAttr()), { width: this.width, height: this.height }));
    }
    getBoundBox() {
        return {
            top: this.y,
            bottom: this.y + this.height,
            left: this.x,
            right: this.x + this.width,
            width: this.width,
            height: this.height
        };
    }
}
exports.Rect = Rect;


/***/ }),

/***/ 117:
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {


Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.Text = void 0;
const base_1 = __webpack_require__(621);
class Text extends base_1.BaseGraph {
    constructor(props) {
        super(props);
        this._text = '';
        this._canvas = document.createElement('canvas');
        this._ctx = this._canvas.getContext('2d');
        this._width = 0;
        this._height = 0;
        this._top = 0;
        this._left = 0;
        this.type = 'text';
        this._text = (props === null || props === void 0 ? void 0 : props.text) || this._text;
    }
    setPath() {
        delete this.path;
        this.path = new Path2D();
        this.initStyle(this._ctx);
        let measure = this._ctx.measureText(this._text);
        this._width = measure.actualBoundingBoxRight;
        this._height = measure.fontBoundingBoxAscent + measure.fontBoundingBoxDescent;
        this._left = -measure.actualBoundingBoxLeft;
        this._top = -measure.fontBoundingBoxAscent;
        this.path.rect(this._left, this._top, this._width, this._height);
    }
    drawPath(ctx) {
        ctx.fillStyle = 'rgba(0,0,0,0)';
        ctx.fill(this.path);
        ctx.fillStyle =
            typeof this.defaultOption.fillStyle == 'string'
                ? this.defaultOption.fillStyle
                : this.defaultOption.fillStyle.get();
        if (this.isFill)
            ctx.fillText(this.text, 0, 0);
        else
            ctx.strokeText(this.text, 0, 0);
    }
    set text(value) {
        this._text = value;
    }
    get text() {
        return this._text;
    }
    clone() {
        return new Text(Object.assign(Object.assign(Object.assign({}, this.option), this.getBaseCloneAttr()), { text: this._text }));
    }
    getBoundBox() {
        return {
            top: this._top,
            bottom: this._top + this._height,
            left: this._left,
            right: this._left + this._width,
            width: this._width,
            height: this._height
        };
    }
}
exports.Text = Text;


/***/ }),

/***/ 799:
/***/ ((__unused_webpack_module, exports) => {


Object.defineProperty(exports, "__esModule", ({ value: true }));
class Matrix {
    constructor(matrix) {
        this.matrix = [1, 0, 0, 1, 0, 0];
        this.min = 0.3;
        this.max = 10;
        this.matrix = matrix || this.matrix;
    }
    reset() {
        this.matrix = [1, 0, 0, 1, 0, 0];
    }
    multiply(a, b) {
        return [
            a[0] * b[0] + a[2] * b[1],
            a[1] * b[0] + a[3] * b[1],
            a[0] * b[2] + a[2] * b[3],
            a[1] * b[2] + a[3] * b[3],
            a[0] * b[4] + a[2] * b[5] + a[4],
            a[1] * b[4] + a[3] * b[5] + a[5]
        ];
    }
    transform(matrixs) {
        if (matrixs.length == 0 || this.matrix.length == 1)
            return this.matrix;
        else {
            for (let i = 0; i < matrixs.length; i++)
                this.matrix = this.multiply(matrixs[i], this.matrix);
        }
        return this.matrix;
    }
    translateMatrix(x, y) {
        return [1, 0, 0, 1, x, y];
    }
    scaleMatrix(scaleX, scaleY) {
        return [scaleX, 0, 0, scaleY, 0, 0];
    }
    rotateMatrix(value) {
        const sinAngle = Math.sin(value);
        const cosAngle = Math.cos(value);
        return [cosAngle, sinAngle, -sinAngle, cosAngle, 0, 0];
    }
    skewMatrix(skewX, skewY) {
        return [1, Math.tan(skewY), Math.tan(skewX), 1, 0, 0];
    }
    translateTo(x, y) {
        this.matrix = this.multiply(this.translateMatrix(x, y), this.matrix);
        return this.matrix;
    }
    scaleTo(scaleX, scaleY) {
        this.matrix = this.multiply(this.scaleMatrix(scaleX, scaleY), this.matrix);
        return this.matrix;
    }
    scaleByPoint(scaleX, scaleY, x, y) {
        this.matrix = this.multiply(this.translateMatrix(-x, -y), this.matrix);
        this.matrix = this.multiply(this.scaleMatrix(scaleX, scaleY), this.matrix);
        this.matrix = this.multiply(this.translateMatrix(x, y), this.matrix);
    }
    clone() {
        return new Matrix([...this.matrix]);
    }
}
exports["default"] = Matrix;


/***/ }),

/***/ 147:
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {


Object.defineProperty(exports, "__esModule", ({ value: true }));
const group_1 = __webpack_require__(926);
class Scene extends group_1.Group {
    constructor(canvas, props) {
        super(props);
        this.children = [];
        this.canvas = null;
        this.zoom = true;
        this.pan = true;
        this.min = 0.3;
        this.max = 10;
        this.ctx = null;
        this.mousedownPosition = { x: -1, y: -1 };
        this.isMousedown = false;
        this.oldMatrix = [];
        this.devicePixelRatio = 1;
        this.height = 0;
        this.width = 0;
        this.centerX = 0;
        this.centerY = 0;
        this.canvas = canvas;
        this.ctx = canvas.getContext('2d');
        this.zoom = (props === null || props === void 0 ? void 0 : props.zoom) == undefined ? this.zoom : props === null || props === void 0 ? void 0 : props.zoom;
        this.pan = (props === null || props === void 0 ? void 0 : props.pan) == undefined ? this.pan : props === null || props === void 0 ? void 0 : props.pan;
        this.min = (props === null || props === void 0 ? void 0 : props.min) || this.min;
        this.max = (props === null || props === void 0 ? void 0 : props.max) || this.max;
        this.devicePixelRatio = window.devicePixelRatio || 1;
        // 高清适配
        this.matrix.matrix = this.matrix.scaleTo(this.devicePixelRatio, this.devicePixelRatio);
        this.addEventListener();
        window.addEventListener('resize', () => this.resize());
        this.resize();
        // this.animate()
    }
    render() {
        this.draw(this.ctx);
    }
    animate() {
        this.render();
        requestAnimationFrame(() => this.animate());
    }
    resize() {
        this.width = this.canvas.clientWidth;
        this.height = this.canvas.clientHeight;
        this.centerX = this.width / 2;
        this.centerY = this.height / 2;
        this.canvas.style.width = this.canvas.clientWidth + 'px';
        this.canvas.style.height = this.canvas.clientHeight + 'px';
        this.canvas.width = this.canvas.clientWidth * this.devicePixelRatio;
        this.canvas.height = this.canvas.clientHeight * this.devicePixelRatio;
    }
    draw(ctx) {
        // 清除因为变换清除不掉的像素
        ctx.resetTransform();
        // 清除画布
        ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
        // 变换矩阵
        // @ts-ignore
        ctx.setTransform(...this.matrix.matrix);
        // 绘制模型
        for (let i = 0; i < this.children.length; i++) {
            this.children[i].draw(ctx);
        }
    }
    clearRect(x, y, width, height) {
        this.ctx.clearRect(x, y, width, height);
    }
    addEventListener() {
        this.canvas.addEventListener('mousedown', this.onMousedown.bind(this), false);
        this.canvas.addEventListener('mousemove', this.onMousemove.bind(this), false);
        this.canvas.addEventListener('mouseup', this.onMouseup.bind(this), false);
        this.canvas.addEventListener('mouseleave', this.onMouseup.bind(this), false);
        this.canvas.addEventListener('wheel', this.onWheel.bind(this), false);
    }
    onMousedown(event) {
        let { x, y } = this.getOffsetPosition(event);
        this.mousedownPosition = { x, y };
        this.oldMatrix = [...this.matrix.matrix];
        if (this.pan)
            this.isMousedown = true;
    }
    onMousemove(event) {
        if (this.isMousedown) {
            let { x, y } = this.getOffsetPosition(event);
            let ox = x - this.mousedownPosition.x;
            let oy = y - this.mousedownPosition.y;
            this.matrix.matrix = this.matrix.multiply(this.matrix.translateMatrix(ox, oy), this.oldMatrix);
        }
    }
    onMouseup(event) {
        let { x, y } = this.getOffsetPosition(event);
        this.isMousedown = false;
        if (this.mousedownPosition.x == x && this.mousedownPosition.y == y) {
        }
    }
    getStartPosition() {
        let x = parseInt(this.canvas.style.borderLeftWidth) || 0;
        let y = parseInt(this.canvas.style.borderTopWidth) || 0;
        return { x, y };
    }
    getOffsetPosition(event) {
        let start = this.getStartPosition();
        return { x: event.offsetX * this.devicePixelRatio - start.x, y: event.offsetY * this.devicePixelRatio - start.y };
    }
    onWheel(event) {
        this.zoomEvent(event);
    }
    zoomEvent(event) {
        if (!this.zoom)
            return;
        let scale = 1;
        let matrix = this.matrix;
        if (event.deltaY > 0) {
            if (matrix.matrix[0] >= matrix.max)
                return;
            scale = 1.05;
        }
        else if (event.deltaY < 0) {
            if (matrix.matrix[0] <= matrix.min)
                return;
            scale = 0.95;
        }
        let { x, y } = this.getOffsetPosition(event);
        this.matrix.scaleByPoint(scale, scale, x, y);
    }
    getBoundBox() {
        return {
            top: 0,
            left: 0,
            bottom: this.canvas.width,
            right: this.canvas.height,
            width: this.canvas.width,
            height: this.canvas.height
        };
    }
    getUrl() {
        return this.canvas.toDataURL('image/png');
    }
    setPath() { }
    drawPath(ctx) { }
}
exports["default"] = Scene;


/***/ }),

/***/ 349:
/***/ ((__unused_webpack_module, exports) => {


Object.defineProperty(exports, "__esModule", ({ value: true }));
function Convert(board, points) {
    let result = [];
    for (let i = 0; i < points.length; i++) {
        result.push([ConvertToNumber(board.width, points[i][0]), ConvertToNumber(board.height, points[i][1])]);
    }
    return result;
}
exports["default"] = Convert;
function ConvertToNumber(size, value) {
    let num = Number(value);
    if (num) {
        return num > 0 ? num : size + num;
    }
    else if (typeof value == 'string') {
        if (value == 'center')
            return size / 2;
        else if (value.match('%'))
            return Number(value.replace('%', '')) / 100;
        else
            console.error('数据类型错误');
    }
    else
        console.error('数据类型错误');
}


/***/ }),

/***/ 886:
/***/ ((__unused_webpack_module, exports) => {


Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.Transform = void 0;
class Transform {
    constructor(graph) {
        this.children = [];
        this.graph = graph;
        this.children.push(this.graph);
        return this;
    }
    array(count, x, y) {
        this.children = new Array(count).fill(undefined).map(() => this.clone(this.children));
        for (let i = 0; i < this.children.length; i++) {
            this.calendar(this.children[i], (graph) => {
                graph.x = graph.x + i * (x || 0);
                graph.y = graph.y + i * (y || 0);
            });
        }
        return this;
    }
    skewX(value) {
        this.calendar(this.children, (graph) => (graph.skewX = value));
        return this;
    }
    skewY(value) {
        this.calendar(this.children, (graph) => (graph.skewY = value));
        return this;
    }
    skew(skewX, skewY) {
        this.calendar(this.children, (graph) => {
            graph.skewX = skewX;
            graph.skewY = skewY;
        });
        return this;
    }
    rotate(angle, increment, increment2) {
        this.calendar(this.children, (graph, index, level) => {
            graph.rotate = angle * (!!increment ? index : 1) * (!!increment2 ? level : 1);
        });
        return this;
    }
    scaleX(value, increment, increment2) {
        this.calendar(this.children, (graph, index, level) => (graph.scaleX = Math.pow(value, (!!increment ? index : 1) * (!!increment2 ? level : 1))));
        return this;
    }
    scaleY(value, increment, increment2) {
        this.calendar(this.children, (graph, index, level) => (graph.scaleY = Math.pow(value, (!!increment ? index : 1) * (!!increment2 ? level : 1))));
        return this;
    }
    scale(scaleX, scaleY, increment, increment2) {
        this.calendar(this.children, (graph, index, level) => {
            let s = (!!increment ? index : 1) * (!!increment2 ? level : 1);
            graph.scale(Math.pow(scaleX, s), Math.pow(scaleY, s));
        });
        return this;
    }
    alpha(value, increment) {
        this.calendar(this.children, (graph, index) => {
            graph.option.alpha = 1 - (!!increment ? index : 0) * value;
        });
        return this;
    }
    origin(value) {
        this.calendar(this.children, (graph) => (graph.origin = value));
        return this;
    }
    draw(ctx) {
        this.calendar(this.children, (graph) => graph.draw(ctx));
    }
    setOption(props) {
        this.calendar(this.children, (graph) => graph.setOption(props));
    }
    mirror(direction, x, y) {
        this.array(2, x * 2 || 0, y * 2 || 0);
        this.calendar(this.children[1], (graph) => {
            if (direction.match('x'))
                graph.scaleX = -graph.scaleX;
            if (direction.match('y'))
                graph.scaleY = -graph.scaleY;
        });
        return this;
    }
    calendar(children, callback, index, level) {
        level = (level || 0) + 1;
        index = index || 0;
        for (let i = 0; i < children.length; i++) {
            if (level == 1)
                index = i;
            if (Array.isArray(children[i]))
                this.calendar(children[i], callback, index, level);
            else
                callback(children[i], index, level);
        }
    }
    clone(children) {
        let result = [];
        for (let i = 0; i < children.length; i++) {
            if (Array.isArray(children[i]))
                result.push(this.clone(children[i]));
            else
                result.push(children[i].clone());
        }
        return result;
    }
}
exports.Transform = Transform;


/***/ })

/******/ 	});
/************************************************************************/
/******/ 	// The module cache
/******/ 	var __webpack_module_cache__ = {};
/******/ 	
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/ 		// Check if module is in cache
/******/ 		var cachedModule = __webpack_module_cache__[moduleId];
/******/ 		if (cachedModule !== undefined) {
/******/ 			return cachedModule.exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = __webpack_module_cache__[moduleId] = {
/******/ 			// no module.id needed
/******/ 			// no module.loaded needed
/******/ 			exports: {}
/******/ 		};
/******/ 	
/******/ 		// Execute the module function
/******/ 		__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/ 	
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/ 	
/************************************************************************/
var __webpack_exports__ = {};
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
(() => {
var exports = __webpack_exports__;
var __webpack_unused_export__;

__webpack_unused_export__ = ({ value: true });
const scene_1 = __webpack_require__(147);
const board_1 = __webpack_require__(354);
const group_1 = __webpack_require__(926);
const circle_1 = __webpack_require__(423);
const rect_1 = __webpack_require__(317);
const text_1 = __webpack_require__(117);
const polyline_1 = __webpack_require__(931);
const polygon_1 = __webpack_require__(623);
const path_1 = __webpack_require__(718);
const transform_1 = __webpack_require__(886);
const lineGradient_1 = __webpack_require__(148);
const convert_1 = __webpack_require__(349);
exports["default"] = {
    Scene: scene_1.default,
    Board: board_1.default,
    Group: group_1.Group,
    Circle: circle_1.Circle,
    Rect: rect_1.Rect,
    Text: text_1.Text,
    Polyline: polyline_1.Polyline,
    Polygon: polygon_1.Polygon,
    Path: path_1.Path,
    Transform: transform_1.Transform,
    LineGradient: lineGradient_1.LineGradient,
    Convert: convert_1.default,
    version: "1.0.0"
};

})();

__webpack_exports__ = __webpack_exports__["default"];
/******/ 	return __webpack_exports__;
/******/ })()
;
});